<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>css模态框</title>
  <style>
    .wrapper {
      height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      background: linear-gradient(to right, #834d9b, #d04ed6);
    }
    .wrapper a {
      display: inline-block;
      text-decoration: none;
      padding: 15px;
      background-color: #fff;
      border-radius: 3px;
      text-transform: uppercase;
      color: #585858;
      font-family: 'Roboto', sans-serif;
    }
    .modal {
      visibility: hidden;
      opacity: 0;
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(77, 77, 77, .7);
      transition: all .4s;
    }
    .modal:target {
      visibility: visible;
      opacity: 1;
    }
    .modal__content {
      border-radius: 4px;
      position: relative;
      width: 500px;
      max-width: 90%;
      background: #fff;
      padding: 1em 2em;
    }
    .modal__close {
      position: absolute;
      top: 10px;
      right: 10px;
      color: #585858;
      text-decoration: none;
    }
  </style>
</head>
<body>
<div class="wrapper">
  <a href="#demo-modal">Open Modal</a>
</div>
<div id="demo-modal" class="modal">
  <div class="modal__content">
      <h2>CSS Modal</h2>
      <p>hello world</p>
      <a href="#" class="modal__close">&times;</a>
  </div>
</div> 
</body>
</html>